using System;
using Unity.VisualScripting;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    [UnitShortTitle("Download")]
    [UnitSurtitle("Start")]
    public sealed class DownloadStart : FrameworkEventUnit<DownloadStartEventArgs>
    {
        protected override int EventId => DownloadStartEventArgs.EventId;
        protected override string HookName => UGFHookNames.DownloadStart;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput SerialId
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DownloadPath
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DownloadUri
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput CurrentLength
        {
            get;
            private set;
        }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput UserData { get; private set; }

        protected override void Definition()
        {
            base.Definition();
            SerialId = ValueOutput<int>(nameof(SerialId));
            DownloadPath = ValueOutput<string>(nameof(DownloadPath));
            DownloadUri = ValueOutput<string>(nameof(DownloadUri));
            CurrentLength = ValueOutput<long>(nameof(CurrentLength));
            UserData = ValueOutput<object>(nameof(UserData));
        }

        protected override void AssignArguments(Flow flow, DownloadStartEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(SerialId, args.SerialId);
            flow.SetValue(DownloadPath, args.DownloadPath);
            flow.SetValue(DownloadUri, args.DownloadUri);
            flow.SetValue(CurrentLength, args.CurrentLength);
            flow.SetValue(UserData, args.UserData);
        }
    }
}